import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// 动态修改根结点文字大小
import "lib-flexible";
// 基础样式
import "./common/style/base.scss";
// 字体图标
import "./assets/iconfont/iconfont.css";
// 按需引入vant组件
import {
  Tabbar,
  TabbarItem,
  Swipe,
  SwipeItem,
  Lazyload,
  Dialog,
  SwipeCell,
  Checkbox,
  CheckboxGroup,
  Stepper,
  Button,
  Divider,
  SubmitBar,
  PullRefresh,
  List 
} from "vant";

Vue.use(Tabbar)
  .use(TabbarItem)
  .use(Swipe)
  .use(SwipeItem)
  .use(Lazyload)
  .use(Dialog)
  .use(SwipeCell)
  .use(Checkbox)
  .use(CheckboxGroup)
  .use(Stepper)
  .use(Button)
  .use(Divider)
  .use(SubmitBar)
  .use(PullRefresh)
  .use(List);

// 懒加载 注册时可以配置额外的选项
Vue.use(Lazyload, {
  lazyComponent: true,
});

// 取消vue的警告
Vue.config.productionTip = false;
// 导航守卫
router.beforeEach((to, from, next) => {
  // auth标志符 对要进行登录的页面进行拦截的标记
  if (to.meta.auth) {
    const userinfo = store.state.userinfo;
    if (userinfo) {
      next();
    } else {
      next("/login");
    }
  } else {
    // 无需登录的页面
    next();
  }
});

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
